package com.ty.day3;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.logging.SimpleFormatter;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/24 11:12
 */
public class CalendarDemo {
    public static void main(String[] args) throws ParseException {
        Calendar calendar= Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        System.out.println(calendar.get(Calendar.YEAR)+"-"+calendar.get(Calendar.MONTH)+"-"
                +calendar.get(Calendar.DATE)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"
        +calendar.get(Calendar.SECOND));
        System.out.println("星期"+(calendar.get(Calendar.DAY_OF_WEEK)==1?7:calendar.get(Calendar.DAY_OF_WEEK)-1));
        calendar.set(2025,9,10,3,24);
        System.out.println(sdf.format(calendar.getTime()));

        GregorianCalendar gregorianCalendar = new GregorianCalendar();

        calendar.set(2002,0,20,0,0,0);
        long time = System.currentTimeMillis();
        System.out.println(calendar.getTime().getTime());
        System.out.println((time-calendar.getTime().getTime())/1000.0/60/60/24);
//        System.out.println(gregorianCalendar.equals(calendar));
//        System.out.println(calendar.getTime().getTime());

    }
}
